Popular Searches
Popular Course Categories
Popular Courses

Creating an Android App Bundle

Creating an Android App Bundle

Flutter Deployment


Creating an Android App Bundle in Flutter


An Android App Bundle (AAB) is the recommended Android release format for publishing Flutter applications on Google Play. Unlike a traditional APK, an app bundle is uploaded to Google Play, which can then generate and deliver optimized APKs for users' devices. Flutter creates a release app bundle using the flutter build appbundle command. :contentReference[oaicite:0]{index=0}




1. What is an Android App Bundle?


An Android App Bundle is a publishing format that contains the compiled application code and resources needed to generate Android APKs for different device configurations.


The AAB file is generally uploaded to Google Play rather than installed directly on an Android device like an APK.


Simple Flow


Flutter Project
      ↓
Dart Source Code
      ↓
Dependencies & Assets
      ↓
Flutter Build Process
      ↓
Android Build System
      ↓
Release App Bundle
      ↓
app-release.aab
      ↓
Google Play
      ↓
Optimized APKs
      ↓
User Devices

2. Why Use an Android App Bundle?



  • Google Play prefers the App Bundle format for Android applications.

  • Google Play can generate optimized APKs for users' devices.

  • Users do not necessarily need to download native binaries that their device does not require.

  • It is suitable for production Android application publishing.

  • It can help provide more efficient application delivery through Google Play.


Flutter's official Android release documentation recommends app bundles over APKs for Google Play because they allow more efficient delivery to users. :contentReference[oaicite:1]{index=1}


3. APK vs AAB










FeatureAPKAAB
Full FormAndroid Package KitAndroid App Bundle
Direct InstallationYesNot normally installed directly as one file
Google PlaySupported in relevant distribution scenariosPreferred publishing format
Flutter Commandflutter build apkflutter build appbundle
Device OptimizationDepends on the APK being distributedGoogle Play generates optimized APKs
Common UsageDirect testing/distributionGoogle Play publishing

4. Requirements for Creating an AAB


Before creating an Android App Bundle, configure the Flutter and Android development environment correctly.



  • Flutter SDK

  • Dart SDK

  • Android SDK

  • Android development tools

  • Java/JDK compatible with the configured Android tooling

  • Flutter project

  • Android build configuration

  • Release signing configuration for production publishing

  • Google Play Developer account when publishing to Google Play


5. Check the Flutter Environment


Use flutter doctor to check the development environment.


flutter doctor

For more detailed environment information:


flutter doctor -v

These commands can help identify Flutter SDK, Android SDK, Java, device, and configuration issues.


6. Create a Flutter Project


If you need to create a new Flutter project, use:


flutter create my_app

Move into the project directory:


cd my_app

7. Flutter Project Structure


my_app/
├── android/
├── ios/
├── lib/
│   └── main.dart
├── test/
├── web/
├── windows/
├── macos/
├── linux/
├── assets/
├── pubspec.yaml
└── build/

The android/ directory contains Android-specific configuration used during Android builds.


8. Install Project Dependencies


Before building the app bundle, resolve the dependencies specified in pubspec.yaml.


flutter pub get

This ensures that packages required by the Flutter application are available to the build process.


9. Test the Application


Before creating a production release, test the application.


flutter test

You can also run the application on an Android device or emulator:


flutter run

Testing before creating the final bundle helps identify application-level problems before distribution.


10. Review pubspec.yaml


The pubspec.yaml file contains important project information such as the application version, dependencies, assets, and other Flutter configuration.


Example


name: my_app
description: A Flutter application

version: 1.0.0+1

environment:
  sdk: '>=3.0.0 <4.0.0'

dependencies:
  flutter:
    sdk: flutter

  http: ^1.0.0

flutter:
  uses-material-design: true
  assets:
    - assets/images/


11. Configure Application Version


The application version can be configured in pubspec.yaml.


version: 1.0.0+1





PartMeaning
1.0.0User-facing version name
1Build number

For Android, Flutter maps the build name to versionName and the build number to versionCode. :contentReference[oaicite:2]{index=2}


12. Update Version Before Publishing


When releasing a new version, update the version information.


version: 1.1.0+2

You can also override these values during the build:


flutter build appbundle --build-name=1.1.0 --build-number=2

13. Android Application ID


The applicationId uniquely identifies an Android application on Google Play and Android devices.


Example


android {
    defaultConfig {
        applicationId = "com.example.myapp"
    }
}

For a production application, use a unique application ID. Flutter's documentation notes that the application ID cannot be changed after the app has been uploaded to Google Play. :contentReference[oaicite:3]{index=3}


14. Android Manifest


The Android manifest is located at:


android/app/src/main/AndroidManifest.xml

Example



            android:label="My Flutter App"
        android:icon="@mipmap/ic_launcher">
   

Review the application label, launcher icon, permissions, and other Android-specific configuration before release.


15. Internet Permission


If the application communicates with APIs or Internet services, verify the Internet permission in the Android manifest.



Flutter's Android release documentation explains that this permission should be added when the application needs Internet access. :contentReference[oaicite:4]{index=4}


16. Configure Application Icon


Before publishing, replace the default launcher icon with the application's final icon.


Android launcher resources are generally located under:


android/app/src/main/res/

The Android manifest references the launcher icon through the android:icon attribute. :contentReference[oaicite:5]{index=5}


17. What is Release Signing?


Android applications distributed through Google Play must be signed with a digital certificate.


Android uses two signing keys in the Play App Signing workflow:



  • Upload key: Used by the developer to sign the app bundle or APK uploaded to Google Play.

  • App signing key: Used to sign the APKs delivered to end users.


Flutter's Android release documentation recommends configuring signing before publishing the application. :contentReference[oaicite:6]{index=6}


18. Create an Upload Keystore


An upload keystore can be generated using Java's keytool.


Windows Example


keytool -genkey -v -keystore %USERPROFILE%\upload-keystore.jks ^
  -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 ^
  -alias upload

macOS/Linux Example


keytool -genkey -v -keystore ~/upload-keystore.jks \
  -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 \
  -alias upload

Keep the keystore secure. Do not upload private signing credentials to public source-control repositories. :contentReference[oaicite:7]{index=7}


19. Create key.properties


Create a file named:


android/key.properties

Example:


storePassword=
keyPassword=
keyAlias=upload
storeFile=

The key.properties file contains sensitive information and should be kept private. :contentReference[oaicite:8]{index=8}


20. Configure Release Signing


The Android Gradle configuration reads the signing properties and applies them to the release build.


Kotlin DSL Example


import java.util.Properties
import java.io.FileInputStream

val keystoreProperties = Properties()
val keystorePropertiesFile = rootProject.file("key.properties")

if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}

android {
    signingConfigs {
        create("release") {
            keyAlias = keystoreProperties.getProperty("keyAlias")
            keyPassword = keystoreProperties.getProperty("keyPassword")
            storeFile = keystoreProperties.getProperty("storeFile")?.let { file(it) }
            storePassword = keystoreProperties.getProperty("storePassword")
        }
    }
}


The exact Gradle configuration depends on the Android project template and Flutter version. Flutter's current Android release documentation provides the corresponding signing configuration for the project's Gradle setup. :contentReference[oaicite:9]{index=9}


21. Build the Android App Bundle


The primary command for creating a release Android App Bundle is:


flutter build appbundle

Flutter's flutter build command defaults to a release build when building the app bundle. :contentReference[oaicite:10]{index=10}


22. Explicit Release Command


You can also specify the release mode explicitly:


flutter build appbundle --release

This makes the intended build mode clear in scripts and documentation.


23. AAB Build Output


After a successful build, the release App Bundle is generated at:


build/app/outputs/bundle/release/app.aab

The official Flutter Android documentation identifies this as the default release bundle output location. :contentReference[oaicite:11]{index=11}


24. Complete AAB Build Flow


Flutter Source Code
        ↓
pubspec.yaml
        ↓
Dependencies
        ↓
Assets
        ↓
Android Configuration
        ↓
Release Signing
        ↓
Dart Compilation
        ↓
Android Build
        ↓
R8 Optimization
        ↓
AAB Packaging
        ↓
app-release.aab
        ↓
Google Play

25. What Happens During AAB Creation?



  1. Flutter reads the project configuration.

  2. Dependencies are resolved.

  3. Dart and Flutter code are compiled for release.

  4. Assets are processed and included in the application.

  5. Android-specific resources are processed.

  6. The Android build system creates the release application.

  7. Release signing is applied when configured.

  8. Code shrinking and optimization are applied to the release build.

  9. The application bundle is generated.

  10. The resulting .aab file can be uploaded to Google Play.


26. Supported Android Architectures


Flutter's release Android app bundle contains native Flutter runtime components for supported architectures including:



  • armeabi-v7a — ARM 32-bit

  • arm64-v8a — ARM 64-bit

  • x86-64 — x86 64-bit


The official Flutter documentation specifies these architectures for release Android builds. :contentReference[oaicite:12]{index=12}


27. Why AAB Does Not Work Like a Normal APK


An APK is an installable Android package. An AAB is a publishing package that Google Play uses to generate APKs suitable for users' devices.


AAB
 ↓
Google Play Processing
 ↓
Device Configuration
 ↓
Optimized APK
 ↓
User Device

This is one reason the AAB format is preferred for Google Play distribution. :contentReference[oaicite:13]{index=13}


28. R8 Code Shrinking


R8 is Google's code shrinker and is enabled by default for release APK and AAB builds in Flutter's Android release process. It helps remove unused Android code from release builds.


Release Build
      ↓
R8 Shrinking
      ↓
Optimized Android Code
      ↓
AAB

Flutter's documentation notes that code shrinking is enabled by default for release builds. :contentReference[oaicite:14]{index=14}


29. Code Obfuscation


Flutter can obfuscate Dart symbols to make the compiled Dart code more difficult to reverse engineer.


Example


flutter build appbundle --obfuscate --split-debug-info=build/symbols

Obfuscation is not encryption. When using it, keep the generated symbol information because it can be required to interpret obfuscated stack traces. :contentReference[oaicite:15]{index=15}


30. Build an Obfuscated Release AAB


flutter clean
flutter pub get
flutter build appbundle --release \
  --obfuscate \
  --split-debug-info=build/symbols

On Windows, use the appropriate command continuation syntax for the shell being used.


31. Clean Build Before Creating AAB


If the project contains stale generated files or you are troubleshooting a build problem, you can clean the generated build artifacts.


flutter clean
flutter pub get
flutter build appbundle

A clean build is useful during troubleshooting but does not need to be performed before every build.


32. Build AAB with a Specific Version


You can specify the version name and build number during the build.


flutter build appbundle --build-name=2.0.0 --build-number=20

This can be useful in automated release workflows.


33. Build AAB with a Flavor


Flutter supports Android product flavors for applications that have separate configurations such as development, staging, and production.


Example


flutter build appbundle --flavor production

A flavor must first be configured in the Android project before it can be used during the build.


Example Flow


Development Flavor
        ↓
Development API
        ↓
Development AAB

Production Flavor
        ↓
Production API
        ↓
Production AAB


34. Multiple Environments


Build flavors can be useful when an application needs different environments.







EnvironmentExample APIPurpose
Developmentdev-api.example.comDeveloper testing
Stagingstaging-api.example.comPre-production testing
Productionapi.example.comLive users

35. Testing an Android App Bundle


An AAB is not normally installed directly on a device as a single file. Flutter's documentation describes two common ways to test an app bundle: using Google's bundletool offline or uploading the bundle to Google Play for testing. :contentReference[oaicite:16]{index=16}


36. Testing with bundletool


The bundletool utility can generate APKs from an Android App Bundle for testing on connected devices.


AAB
 ↓
bundletool
 ↓
Generated APK Set
 ↓
Connected Android Device

The exact bundletool commands depend on the testing setup and signing configuration.


37. Testing Through Google Play


You can upload the AAB to Google Play and use testing tracks such as the internal testing track before a production release.


Flutter AAB
    ↓
Google Play Console
    ↓
Internal Testing
    ↓
Testers
    ↓
Feedback
    ↓
Production Release

Flutter's Android deployment documentation describes internal testing and other pre-production testing channels as ways to test an app bundle through Google Play. :contentReference[oaicite:17]{index=17}


38. AAB and Google Play


A typical production publishing workflow looks like:


Flutter Application
       ↓
Test Application
       ↓
Configure Release
       ↓
Configure Signing
       ↓
flutter build appbundle
       ↓
app-release.aab
       ↓
Google Play Console
       ↓
Testing Track
       ↓
Production Release

39. Preparing the App for Google Play


Before uploading an AAB, review the application's Android release configuration.



  • Application ID

  • Application name

  • Launcher icon

  • Version name

  • Version code

  • App permissions

  • Internet permission if required

  • Release signing

  • Application functionality

  • Production API configuration

  • Privacy and store information required by Google Play


40. Application ID Example


applicationId = "com.mycompany.myapp"

The application ID should be unique and should be selected carefully before publishing. Flutter's documentation notes that changing an application ID after uploading the app to Google Play is not supported. :contentReference[oaicite:18]{index=18}


41. Versioning Example


version: 1.0.0+1

After releasing an update:


version: 1.1.0+2

Each new Google Play release should use an appropriate version code/build number that is greater than the previous one.


42. App Bundle Signing Flow


Upload Keystore
       ↓
key.properties
       ↓
Gradle Signing Configuration
       ↓
Release Build
       ↓
Signed AAB
       ↓
Google Play

43. Upload Key vs App Signing Key






KeyPurpose
Upload KeyUsed by the developer to sign the bundle uploaded to Google Play.
App Signing KeyUsed by Google Play to sign APKs delivered to users when Play App Signing is used.

Flutter's Android release documentation describes this two-key model for Play App Signing. :contentReference[oaicite:19]{index=19}


44. Protect Signing Credentials


Signing credentials are sensitive information.



  • Do not publish keystore passwords.

  • Do not upload private keystores to public repositories.

  • Do not commit key.properties to public source control.

  • Use secure storage for signing credentials.

  • Restrict access to production signing files.

  • Back up important signing credentials securely.


45. Common AAB Build Errors


Error 1: Gradle Build Failure


Possible Causes:



  • Android Gradle configuration problems.

  • Incompatible dependencies.

  • Incorrect SDK configuration.

  • Signing configuration problems.

  • Stale build files.


For troubleshooting, you can try:


flutter clean
flutter pub get
flutter build appbundle

Error 2: Signing Configuration Error


Possible Causes:



  • Incorrect keystore path.

  • Wrong keystore password.

  • Wrong key alias.

  • Incorrect key.properties configuration.

  • Gradle signing configuration problem.


Error 3: Dependency Resolution Error


Run:


flutter pub get

Then try the build again.


Error 4: Application ID Problem


Check the Android applicationId configuration and make sure it matches the intended application identity.


Error 5: Missing Asset


Check the asset declaration in pubspec.yaml.


flutter:
  assets:
    - assets/images/

Flutter bundles assets declared in the assets section of the flutter section of pubspec.yaml. :contentReference[oaicite:20]{index=20}


46. Common Mistakes



  • Publishing without testing the release build.

  • Forgetting to configure release signing.

  • Using an incorrect application ID.

  • Forgetting to increase the build number for an update.

  • Uploading private signing information to GitHub.

  • Using development API endpoints in production.

  • Forgetting to verify application permissions.

  • Not checking the final application icon and name.

  • Not testing the AAB through an appropriate testing channel.

  • Assuming that a successful build automatically means the application is ready for production.


47. Best Practices



  • Run flutter doctor when configuring or troubleshooting the environment.

  • Run automated tests before creating the release bundle.

  • Use release mode for production builds.

  • Maintain proper versioning.

  • Use a unique application ID.

  • Configure release signing securely.

  • Protect keystores and passwords.

  • Keep obfuscation symbol files securely when obfuscation is enabled.

  • Test the release AAB before production release.

  • Use Google Play testing tracks before production distribution.

  • Keep development and production configurations separate.


48. Complete AAB Creation Workflow


Step 1: Create Flutter Application
        ↓
Step 2: Configure Application
        ↓
Step 3: Add Dependencies
        ↓
Step 4: Configure Assets
        ↓
Step 5: Set Application ID
        ↓
Step 6: Set Version
        ↓
Step 7: Configure Android
        ↓
Step 8: Configure Release Signing
        ↓
Step 9: Test Application
        ↓
Step 10: Run flutter build appbundle
        ↓
Step 11: Generate app-release.aab
        ↓
Step 12: Test AAB
        ↓
Step 13: Upload to Google Play
        ↓
Step 14: Release to Users

49. Complete Command Example


flutter doctor
flutter pub get
flutter test
flutter clean
flutter pub get
flutter build appbundle

50. Production AAB with Obfuscation


flutter build appbundle --release \
  --obfuscate \
  --split-debug-info=build/symbols

Keep the generated symbol files securely if obfuscation is used so that obfuscated stack traces can later be interpreted.


51. AAB Build Checklist

















TaskStatus
Flutter environment checked
Android SDK configured
Dependencies installed
Application tested
Application ID configured
Application version updated
Assets verified
Launcher icon configured
Release signing configured
Signing credentials protected
AAB generated
AAB tested
Google Play testing completed

52. Interview Questions


Q1. What is an Android App Bundle?


An Android App Bundle is a publishing format containing an Android application's compiled code and resources. Google Play uses it to generate optimized APKs for users' devices.


Q2. Which Flutter command creates an Android App Bundle?


flutter build appbundle

Q3. Where is the generated AAB located?


build/app/outputs/bundle/release/app.aab

Q4. Is an AAB directly installed on an Android phone?


An AAB is primarily a publishing format. For testing, it can be converted to APKs using appropriate tools such as bundletool or uploaded to Google Play testing tracks.


Q5. Why is AAB preferred over APK for Google Play?


Google Play can use the bundle to deliver optimized APKs to users based on their device configuration.


Q6. How do you build an AAB with a specific version?


flutter build appbundle --build-name=1.1.0 --build-number=2

Q7. How do you build an obfuscated AAB?


flutter build appbundle --obfuscate --split-debug-info=build/symbols

Q8. What is release signing?


Release signing uses a digital signing key to establish the identity and authenticity of an Android application for release and distribution.


Q9. What is the difference between an upload key and an app signing key?


The upload key is used by the developer to sign the application uploaded to Google Play, while the app signing key is used to sign the APKs delivered to users through Google Play's app-signing process.


Q10. How can an AAB be tested?


An AAB can be tested using bundletool-generated APKs or through Google Play testing tracks such as internal testing. :contentReference[oaicite:21]{index=21}


53. Summary


Creating an Android App Bundle in Flutter involves preparing the Flutter project, resolving dependencies, configuring Android settings, setting the application ID and version, configuring release signing, testing the application, and running the flutter build appbundle command.


The most important command is:


flutter build appbundle

The resulting release bundle is normally generated at:


build/app/outputs/bundle/release/app.aab

For Google Play distribution, the AAB is uploaded to Google Play, where the platform can generate optimized APKs for users' devices. :contentReference[oaicite:22]{index=22}




54. Learn Flutter with JustAcademy


JustAcademy Flutter Training Course


Register for Flutter Course Demo


whatsapp